// Copyright (c) 2010 Lup Gratian
package Rendering.Animations;
import Rendering.*;

public final class LayerAnimation extends AnimationBase {
    private double start_;
    private double end_;
    IRenderer renderer_;
    
    /*
     * Constructori.
     */
    public LayerAnimation(IAnimatable parent, IRenderer renderer,
                          double start, double end, long duration,
                          IInterpolation interpolation){
        super(parent, duration, interpolation);
        start_ = start;
        end_ = end;
        renderer_ = renderer;
    }

    /*
     * Metode publice.
     */
    @Override
    public void Update() {
        renderer_.SetOpacity(Interpolation().GetValue(start_, end_, Progress()));
        renderer_.SetVisible(renderer_.Opacity() > 0.01);
    }

    @Override
    public void Start() {
        renderer_.SetVisible(true);
        StartWatch();
    }
    public double Opacity() { return renderer_.Opacity(); }
    public IRenderer Renderer() { return renderer_; }
}